package com.aptemo.webetek.server.handlers;

import com.aptemo.webetek.client.commands.Action;
import com.aptemo.webetek.client.commands.impl.GetPlayerDetailsAction;
import com.aptemo.webetek.client.exceptions.BackendException;
import com.aptemo.webetek.client.exceptions.WebetekLoginException;
import com.aptemo.webetek.server.datastore.DataStoreAPI;
import com.aptemo.webetek.shared.UserBean;

public class PlayerDetailsHandler
		extends ActionHandler<GetPlayerDetailsAction, UserBean>
{

	public PlayerDetailsHandler(DataStoreAPI dataService)
	{
		super(dataService);
	}

	public Class<? extends Action<?>> getActionType()
	{
		return GetPlayerDetailsAction.class;
	}

	@Override
	public UserBean invoke(GetPlayerDetailsAction action) throws BackendException, WebetekLoginException
	{
		utils.checkLogin();

		return dataService.getPlayer(action.getUserId());
	}

}
